home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tas412.zip / SELCT.TAS < prev    next >
Text File  |  1992-12-18  |  7KB  |  203 lines

  1. #MAX_QUOTES 200
  2. #OUTPUT_FILE 'SELECT.LST'
  3. SHOW_ALL equal to zero if you only want to show BUY/SELL SIGNALS
  4. }
  5. SHOW_ALL = 1;            
  6.  
  7. {
  8.   ---------------------  STUDY1.scr ---------------------------
  9.    This script contains the "Achelis Binary Wave(tm)" calculation
  10.    shown in the Metastock(*) 2.0 distribution system. It has been
  11.    modified to include the following indicators as well:
  12.                                     BUY         SELL
  13.       Chaikin's Oscillator          > 0         < 0
  14.       Commodity Channel Index      > 100       < -100
  15.    It is here to give an example of the kind of analysis
  16.    available with the TAS Script language.
  17.    The Metastock manual discusses this binary wave system on
  18.    page 187 of the User's Manual.
  19.    The script will put out a message if the value of the binary
  20.    wave changes from yesterday to today (the terms 'today' and
  21.    'yesterday' are used loosely, but meant to be the 'latest day'
  22.    and the 'day before', respectively).
  23.    Two variables are defined and updated as each of the four
  24.    individual binary wave formulas are checked.
  25.    They are:
  26.    "t_bwave" which is today's binary wave value (-6 to +6)
  27.             and
  28.    "y_bwave" which is yesterday's binary wave value (-6 to +6)
  29.    What we are looking for is a TRANSITION from yesterday to
  30.    today. If the stock moved to +6 today and it was lower yesterday,
  31.    perhaps this is a buying opportunity. If the stock moved to -6
  32.    perhaps it is a short sell.
  33. }
  34. y_total : number;        { yesterday's total bwave }
  35. t_total : number;        { today's total bwave value }
  36. c_total : number;        { total changed bwave values}
  37. tick_total : number;     { ticker count }
  38. sell_count : number;     { total SELL's given }
  39. buy_count : number;      { total BUY's given }
  40. MACD_ARRAY : ARRAY;    { Place to put values for TODAY }
  41. MACDTRIG_ARRAY : ARRAY;
  42. MA20 : ARRAY;
  43. ROC12 : ARRAY;           { PLACE TO PUT RATE OF CHANGE }
  44. STOCH53 : ARRAY;                { PLACE TO PUT STOCH(5,3) VALUES }
  45. CO_ARRAY : ARRAY;
  46. CCI14 : ARRAY;          { PLACE TO PUT CCI(14) VALUES }
  47. y_bwave := 0;     { this is our 'score' yesterday}
  48. t_bwave := 0;     { this is our 'score' today}
  49. alert   := '         ';
  50. if FIRST_TICKER then
  51. begin
  52.     good_date = dates[0];   { check's for files not current }
  53.     writeln('                         --BINARY WAVE--        ');
  54.     writeln('TICKER  FULLNAME         PRIOR CURR  CHNG  ALERT    CLOSE');
  55.     y_total = 0;        { yesterday's total bwave }
  56.     t_total = 0;        { today's total bwave value }
  57.     c_total = 0;        { total changed bwave values}
  58.     tick_total = 0;     { ticker count }
  59.     sell_count = 0;     { SELL count }
  60.     buy_count = 0;      { BUY count }
  61. end;
  62. { SKIP any tickers which are not 'up-to-date'}
  63. if good_date = dates[0] then
  64. BEGIN
  65.     {
  66.        First compute MACD Binary Wave for yesterday and today
  67.        Note that MACD() computes the 12 day EMA - 26 day EMA and places
  68.        the result in the array MACD_ARRAY. The 9 day EMA is computed
  69.        and placed in the result array MACDTRIG_ARRAY
  70.     }
  71.     MACD_ARRAY = MACD();
  72.     MACDTRIG_ARRAY = MACDTRIGGER();
  73.     {
  74.        Now compute 20-MA B-Wave
  75.     }
  76.     MA20 := mov(c,20,'E');   { Compute 20 unit EMA of close }
  77.     {
  78.        Now compute 12-ROC B-Wave
  79.     }
  80.     ROC12 := roc(c,12,'%');
  81.     {
  82.        Now compute 5-3 stochastic B-wave
  83.     }
  84.     STOCH53 := stoch(5,3);          { compute stoch(%K period, %K slow) }
  85.     {
  86.         check if Chaikin's AD oscillator is above or below 0
  87.     }
  88.     CO_ARRAY := CO();       { PLACE CHAIKIN'S OSCILLATOR IN CO_ARRAY}
  89.     {
  90.         check if CCI(14)  above +100 or below -100
  91.     }
  92.     CCI14 := cci(14);
  93.  
  94.    { All arrays are calculated. Now do the checking of change }
  95.     IF MACD_ARRAY[0] > MACDTRIG_ARRAY[0] THEN
  96.        t_bwave := t_bwave + 1    { macd greater than trigger }
  97.     else
  98.        t_bwave := t_bwave - 1;   { macd less than trigger    }
  99.     if MACD_ARRAY[-1] > MACDTRIG_ARRAY[-1] then
  100.        y_bwave := y_bwave + 1    { macd greater than trigger }
  101.     else
  102.        y_bwave := y_bwave - 1;   { macd less than trigger    }
  103.     if c[0] > MA20 then    { compare today's close to today's ema}
  104.        t_bwave := t_bwave + 1    { ema greater than close }
  105.     else
  106.        t_bwave := t_bwave - 1;   { ema less than close    }
  107.     if c[-1] > MA20[-1] then    { compare yesterday's close to today's ema}
  108.        y_bwave := y_bwave + 1    { ema greater than close }
  109.     else
  110.        y_bwave := y_bwave - 1;   { ema less than close    }
  111.     if ROC12 > 0 then
  112.        t_bwave := t_bwave + 1    { roc greater than 0 }
  113.     else
  114.        t_bwave := t_bwave - 1;   { roc less than 0    }
  115.     if ROC12[-1] > 0 then
  116.        y_bwave := y_bwave + 1    { roc greater than 0 }
  117.     else
  118.        y_bwave := y_bwave - 1;   { roc less than 0    }
  119.     if STOCH53[0] > 50 then
  120.        t_bwave := t_bwave + 1    { stoch greater than 50 }
  121.     else
  122.        t_bwave := t_bwave - 1;   { stoch less than 50    }
  123.     if STOCH53[-1] > 50 then
  124.        y_bwave := y_bwave + 1    { stoch greater than 50 }
  125.     else
  126.            y_bwave := y_bwave - 1;   { stoch less than 50    }
  127.     IF CO_ARRAY[0] > 0 THEN
  128.         t_bwave := t_bwave + 1
  129.     else
  130.         t_bwave := t_bwave - 1;
  131.     IF CO_ARRAY[-1] > 0 THEN
  132.         y_bwave := y_bwave + 1
  133.     else
  134.         y_bwave := y_bwave - 1;
  135.     if CCI14[0] < -100 then
  136.        t_bwave := t_bwave - 1
  137.     else
  138.     if CCI14[0] > 100 then
  139.        t_bwave := t_bwave + 1;
  140.     if CCI14[-1] < -100 then
  141.        y_bwave := y_bwave - 1
  142.     else
  143.     if CCI14[-1] > 100 then
  144.        y_bwave := y_bwave + 1;
  145.     {
  146.        Okay, here we are at the end of the script. We have boiled
  147.        the formulas down to two values:
  148.        "t_bwave" which is today's binary wave value (-6 to +6)
  149.                 and
  150.        "y_bwave" which is yesterday's binary wave value (-6 to +6)
  151.     }
  152.     {
  153.        First, let's check if the wave moved to +6..if so, let's print
  154.        out it's value then and now
  155.     }
  156.     y_bwave := INT(y_bwave);   { make y_bwave into an INTEGER }
  157.     t_bwave := INT(t_bwave);   { make t_bwave into an INTEGER }
  158.     diff := INT(t_bwave-y_bwave);
  159.     tick_total = tick_total + 1;    { add to count of tickers }
  160.     y_total = y_total + y_bwave;    { add yesterday's bwave to total}
  161.     t_total = t_total + t_bwave;    { add today's bwave to total}
  162.     c_total = c_total + diff;    { add diff in bwave to total}
  163.     buy_flag = 0;
  164.     sell_flag = 0;
  165.     alert = '         ';
  166.     if ((y_bwave < 6) and (t_bwave = 6)) then
  167.     begin
  168.         buy_flag = 1;
  169.         alert = '   BUY   ';
  170.         buy_count = buy_count + 1;
  171.     end
  172.     {
  173.        Now, let's check if the wave moved to -6..if so, let's print
  174.        out it's value then and now
  175.     }
  176.     else
  177.     if ((y_bwave > -6) and (t_bwave = -6)) then
  178.     begin
  179.         sell_flag =  1;
  180.         alert = '   SELL  ';
  181.         sell_count = sell_count + 1;
  182.     end;
  183.     if (show_all = 1) or (buy_flag = 1) or (sell_flag = 1) then
  184.     begin
  185.        { Write out the line with the current alert }
  186.        write(TICKER,fullname,' ');
  187.        write(y_bwave,t_bwave,diff);
  188.        writeln(alert,c);
  189.     end;
  190. END;     { of if good_date = date }
  191. if last_ticker then
  192. begin
  193.    writeln('\t\t\n\n------------- SUMMARY--------------------');
  194.    writeln('\tTickers Processed             ',INT(tick_total));
  195.    writeln('\tYesterday Binary Wave Average ',y_total/tick_total);
  196.    writeln('\tToday Binary Wave Average     ',t_total/tick_total);
  197.    writeln('\tAverage Change in Binary Wave ',c_total/tick_total);
  198.    writeln('\t',INT(buy_count),' BUY Signals');
  199.    writeln('\t',INT(sell_count),' SELL Signals');
  200. end;
  201.  
  202.